﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace BestCode.Creds.UI.Common
{
    public class WindowUtil
    {
        public static Window GetParentWindow(DependencyObject child)
        {
            DependencyObject parentObject = VisualTreeHelper.GetParent(child);

            if (parentObject == null)
            {
                return null;
            }

            Window parent = parentObject as Window;
            if (parent != null)
            {
                return parent;
            }
            else
            {
                return GetParentWindow(parentObject);
            }
        }

        public static void ApplyEffect(Window win)
        {
            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            objBlur.Radius = 4;
            win.Effect = objBlur;
            //win.Background = new SolidColorBrush(Colors.Chartreuse);


        }
        /// <summary>
        /// Remove Blur Effects
        /// </summary>
        /// <param name=”win”></param>
        public static void ClearEffect(Window win)
        {
            win.Effect = null;
        }

    }
}
